﻿<!-- <SnippetCustomCommandMapping-->
<Window x:Class="SDKSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:custom="clr-namespace:SDKSample"
    Title="Custom RoutedCommand Sample"
    Name="RootWindow" Height="500" Width="600"
    Focusable="True">
	<Window.Resources>
		

    <Style x:Key="MyFocusVisual">
      <Setter Property="Control.Template">
        <Setter.Value>
          <ControlTemplate>
            <Rectangle Margin="-2" StrokeThickness="3" Stroke="Red" StrokeDashArray="1 2"/>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

  </Window.Resources>
  <!-- </SnippetCustomCommandMapping-->
  <!--<SnippetCustomCmdBinding>-->
  <Window.CommandBindings>
    <CommandBinding Command="{x:Static custom:Window1.ColorCmd}"
                    Executed="ColorCmdExecuted"
                    CanExecute="ColorCmdCanExecute"/>
  </Window.CommandBindings>
  <!--</SnippetCustomCmdBinding>-->
  <DockPanel>
    <Menu DockPanel.Dock="Top"
          Height="25">
      <MenuItem Header="Commands">
        <MenuItem Header="Color Command"
                  Command="{x:Static custom:Window1.ColorCmd}" />
      </MenuItem>
    </Menu>
    <Border BorderBrush="Black" BorderThickness="1" Margin="10"
            Height="165" Width="250" DockPanel.Dock="Top">
      <TextBlock TextWrapping="Wrap" Margin="3">
        The Color Command chages the background color of a StackPanel.
        <LineBreak/>
        <LineBreak/>
        In order for the command attached to the MenuItem to be enabled, the
        StackPanel must have keyboard focus.  Use the TAB key to change focus.
        <LineBreak/>
        <LineBreak/>
        Since the command attached to the Button has the CommandTarget
        set to the first StackPanel, the StackPanel does not need focus.
        <LineBreak/>
      </TextBlock>
    </Border>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
                DockPanel.Dock="Bottom">
      <Border Margin="10"
              Height="200" Width="200" >
        <StackPanel Name="FirstStackPanel"
                    Background="AliceBlue"
                    Focusable="True"
                    FocusVisualStyle="{StaticResource MyFocusVisual}"
                    >
          <!-- <SnippetCustom_RoutedCommandCommandBinding> -->
          <StackPanel.CommandBindings>
            <CommandBinding Command="{x:Static custom:Window1.ColorCmd}"
                            Executed="ColorCmdExecuted"
                            CanExecute="ColorCmdCanExecute"/>
          </StackPanel.CommandBindings>
          <!-- <SnippetCustom_RoutedCommandCommandBinding> -->

          <Label>First StackPanel</Label>

          
          <!-- </SnippetCustom_RoutedCommandCommandSource> -->
        </StackPanel>
      </Border>
      <Border BorderBrush="Black" BorderThickness="1" Margin="10"
              Height="200" Width="200">
        <StackPanel Background="AliceBlue" Focusable="True" 
          FocusVisualStyle="{StaticResource MyFocusVisual}"
          >
          <Label>Second StackPanel</Label>
		  <!-- <SnippetCustom_RoutedCommandCommandSource> -->
          <Button Command="{x:Static custom:Window1.ColorCmd}"
                  CommandParameter="ButtonOne"
                  CommandTarget="{Binding ElementName=FirstStackPanel}" 
                  Content="CommandTarget = FirstStackPanel" 
                  
                  
                  />
          
          
        </StackPanel>
      </Border>
    </StackPanel>
  </DockPanel>
</Window>
